﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using _180FrameWork.Common;

namespace _180FrameWork.CustControls
{
    public partial class CustGroupBox : GroupBox
    {
        public CustGroupBox()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="bs"></param>
        public void Binding(object bs)
        {
            foreach (Control item in this.Controls)
            {
                Binding(bs, item);
            }
        }

        private void Binding(object bs, Control c)
        {
            foreach (Control item in c.Controls)
            {
                if (item is ICustControl)
                {
                    ICustControl i = (ICustControl)item;
                    if (i.PropertName != null && i.PropertName != "")
                        i.Binding(bs, i.PropertName);
                    //else
                    //    i.Binding(bs, i.Name);
                }
                else
                {
                    Binding(bs, item);
                }
            }
        }
        ///// <summary>
        ///// 获取查询数据
        ///// </summary>
        ///// <returns></returns>
        //public IDictionary<string, string> GetQueryParams()
        //{
        //    IDictionary<string, string> dict = new Dictionary<string, string>();
        //    foreach (Control item in this.Controls)
        //    {
        //        GetQueryParams(dict, item);
        //    }
        //    return dict;
        //}

        //private void GetQueryParams(IDictionary<string, string> dict, Control c)
        //{
        //    foreach (Control item in c.Controls)
        //    {
        //        if (item is ICustControl)
        //        {
        //            ICustControl i = (ICustControl)item;
        //            if (i.QueryName != null && i.QueryName != "")
        //                dict.Add(i.QueryName, i.GetValue().ToStr());
        //        }
        //        else
        //        {
        //            GetQueryParams(dict, item);
        //        }
        //    }
        //}

    }
}
